#ifndef PISTE_H
#define PISTE_H

#include <phonon/mediaobject.h>
#include <phonon/mediasource.h>
#include <QtCore>
#include <QtGui>

/* 

This class represents a track with: 
	* the path of the track
	* the artist who performed the track, 
	* the title of the track, 
	* it's legth(in ms), 
	* the album which contains the track, 
	* the genre(e.g., Rap, Classic, Rock) and 
	* the tracknumber(the track's position in the album)

resolve() function launch the filling of this fields: when it's done, metaDataResolved() signal is emitted

*/

class Track : public QObject
{
	Q_OBJECT
	private:
		QString path;
		QString artist;
		QString title;
		qint64 length;
		QString album;
		int trackNumber;
		QString genre;
		Phonon::MediaObject *mediaResolver;
		bool resolved, r_metaData, r_time;
		
		int id;
		
	public:
		Track();
		Track(QString path);
		Track(QString path, QString artist, QString title, int length, QString album, int trackNumber, QString genre);
		QString getPath() const;
		QString getArtist() const;
		QString getTitle() const;
		QString getAlbum() const;
		int getTrackNumber() const;
		qint64 getLength() const;
		QString displayLength() const;
		QString getGenre() const;
		int getId() const;
		void setPath(QString path);
		void setArtist(QString artist);
		void setTitle(QString title);
		void setLength(qint64 length);
		void setAlbum(QString album);
		void setTrackNumber(int trackNumber);
		void setGenre(QString genre);
		void setLastId(int id);
		void setResolved(bool);
		void resolve();
		bool isResolved();
		static QVector<QString> columns;
		static int lastId;
		static void fillColumns();
		
		bool operator==(const Track & other);
		QVariant operator[](int off);
		
	public slots:
		void onMediaResolverMetaDataChanged();
		void onMediaResolverStateChanged(Phonon::State, Phonon::State);
		
	signals:
		void metaDataResolved(int);
};

#endif
